/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commons.log;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.net.SMTPAppender;

/**
 *
 * @author Swang
 */
public class JCLTest {

    private static Log log = LogFactory.getLog(JCLTest.class);
    private static Log log2 = LogFactory.getLog("commons.log");
    private static Log log3 = LogFactory.getLog("clog");
    private static Log mailLog = LogFactory.getLog("mail");
    private static Logger log4j = Logger.getLogger("mail");
    private static SMTPAppender appender = new SMTPAppender();

    public static void main(String[] args) {
        log.error("Test log error");
        log2.info("Test log info");
        log3.fatal("Test log fatal");
        log3.info("Test log info log3");
        mailLog.fatal("This is a error!!");
        /*
         * 通过代码发送Email
        appender.setTo("magicshuai@gmail.com");
        appender.setFrom("info33@hengzhimail.cc");
        appender.setSMTPHost("mail.hengzhimail.cc");
        appender.setLocationInfo(true);
        appender.setSubject("Test Mail From Log4J2");
        appender.setLayout(new PatternLayout());
        appender.activateOptions();
        log4j.addAppender(appender);
        log4j.fatal("Log4j Error!");
         */
    }
}
